//
//  ZqmNavigationController.swift
//  weibo
//
//  Created by 张清美 on 16/3/2.
//  Copyright © 2016年 张清美. All rights reserved.
//

import UIKit


class ZqmNavigationController: UINavigationController {
    
    
    override func viewDidLoad() {
        
        
        super.viewDidLoad()
        //重写父类的方法
        
        
        
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0{
            
            var title = "返回"
            
            if childViewControllers.count == 1{
            
            //第二个控制器显示第一个控制器的标题
               title = childViewControllers.first?.title ?? "返回"
            
           
            
            }
            
            //添加自己的逻辑
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: title, target:  self, action: "Back")
            
            
            
            //隐藏底部工具条
            viewController.hidesBottomBarWhenPushed = true
            
        
        
        }
        //调用父类的方法
        super.pushViewController(viewController, animated: true)
        
    }
    
    func Back(){
    
    popViewControllerAnimated(true)
    
    
    
    }

}
